package com.kbs.changwonlove.task;

import org.json.JSONObject;

import com.kbs.changwonlove.activity.CWLMainActivity;
import com.kbs.changwonlove.activity.CWLWebviewActivity;
import com.kbs.changwonlove.common.CommonApplication;
import com.kbs.changwonlove.util.HttpRequestUtil;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.widget.MultiAutoCompleteTextView.CommaTokenizer;

public class CWLCheckListTask extends AsyncTask<String, String, String> {

	Context mContext;
	
	public CWLCheckListTask(Context context){
		mContext = context;
	}
	
	@Override
	protected String doInBackground(String... arg0) {
		// TODO Auto-generated method stub
		try {
			JSONObject obj = HttpRequestUtil.deviceIns(mContext);
			
			String result = obj.getString("success");
			
			return result;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected void onCancelled() {
		// TODO Auto-generated method stub
		super.onCancelled();
	}

	@Override
	protected void onPostExecute(String result) {
		// TODO Auto-generated method stub
		super.onPostExecute(result);
		
		Intent intent = new Intent(mContext,CWLWebviewActivity.class);
		//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		mContext.startActivity(intent);
		((Activity)mContext).finish();
		this.cancel(true);
	}

	@Override
	protected void onPreExecute() {
		// TODO Auto-generated method stub
		super.onPreExecute();
	}

	@Override
	protected void onProgressUpdate(String... values) {
		// TODO Auto-generated method stub
		super.onProgressUpdate(values);
	}

}
